
# Copyright 2013 Aditya Naik
# Licensed under the Apache License, Version 2.0
# http://www.apache.org/licenses/LICENSE-2.0


"""A tiny module for creating lists of abspath of files in a directory.
	Also creates lists by isolating the files of the required extension."""

import re
import os
import sys


def listpaths(path):
	"""Get a list of all  files"""
	global filedir
	filedir=[]
	filepath=os.listdir(path)
	for filename in filepath:
		filedir.append(os.path.join(os.path.abspath(path),filename))
	return filedir

	
def listext(path,ext):
	"""This function will list all files in the specified path with the given extension"""
	global filedir
	filedir=[]
	filepath=os.listdir(path)
	for filename in filepath:
		filedir.append(os.path.join(os.path.abspath(path),filename))
	i=0
	while i <len(filedir):
			if filedir[i][-len(ext):]!=ext: filedir.pop(i)
			else: i=i+1
	return filedir
	
